import 'package:dash/contants/controllers.dart';
import 'package:dash/contants/style.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../cus_text.dart';

class VMenuItem extends StatelessWidget {
  final String itemName;
  final void Function() onTap;
  const VMenuItem(this.itemName, {Key? key, required this.onTap})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: onTap,
      onHover: (value) => value
          ? menuController.onHover(itemName)
          : menuController.onHover("not Hovering"),
      child: Obx(
        () => Container(
          color: menuController.isHovering(itemName)
              ? lightGrey.withOpacity(.1)
              : Colors.transparent,
          child: Row(
            children: [
              Visibility(
                visible: menuController.isHoverOrActive(itemName),
                maintainSize: true,
                maintainState: true,
                maintainAnimation: true,
                child: Container(
                  width: 3,
                  height: 72,
                  color: dark,
                ),
              ),
              Expanded(
                  child: Column(
                mainAxisSize: MainAxisSize.min,
                children: [
                  Padding(
                    padding: const EdgeInsets.all(16),
                    child: menuController.getIconFor(itemName),
                  ),
                  menuController.isActive(itemName)
                      ? Flexible(
                          child: CusText(
                          itemName,
                          color: dark,
                          size: 18,
                          weight: FontWeight.bold,
                        ))
                      : Flexible(
                          child: CusText(itemName,
                              color: menuController.isHovering(itemName)
                                  ? dark
                                  : lightGrey)),
                ],
              ))
            ],
          ),
        ),
      ),
    );
  }
}
